<?php namespace App\Http\Controllers\Site;

use App\Item;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Request;

class IndexController extends Controller
{
    public function getIndex()
    {
        $news_lists = Item::where('type', 'news')->orderBy('kind', 'ASC')->orderBy('updated_at', 'DESC')->paginate(4);
        $news_hots = Item::where('type', 'news')->orderBy('kind', 'DESC')->orderBy('updated_at', 'DESC')->take(3)->get();
        $aqs = Item::where('type', 'aq')->orderBy('updated_at', 'DESC')->take(4)->get();
        $vedio = Item::where('type', 'vedio')->orderBy('kind', 'DESC')->first();
        $qq = Item::where('type', 'qq')->orderBy('kind', 'DESC')->get();
        return view('site.index', [
            'news_lists' => $news_lists,
            'news_hots' => $news_hots,
            'vedio' => $vedio,
            'aqs' => $aqs,
            'qq' => $qq,
        ]);
    }

    public function getAbout()
    {
        return view('site.about');
    }

    public function getMap()
    {
        return view('site.map');
    }

    public function getContact()
    {
        return view('site.contact');
    }

    public function getServicesupport()
    {
        $directions = Item::where('type', 'direction')->get();
        return view('site.serviceSupport', [
            'directions' => $directions
        ]);
    }

    public function getServicevedio()
    {
        $vedio = Item::where('type', 'vedio')->orderBy('kind', 'DESC')->first();
        $vedios = Item::where('type', 'vedio')->orderBy('created_at', 'DESC')->take(5)->get();
        return view('site.serviceVedio', [
            'vedios' => $vedios,
            'vedio' => $vedio,
        ]);
    }

    public function getServiceaq()
    {
        $hardWareAqs = Item::where('type', 'aq')->where('kind', 0)->orderBy('created_at', 'DESC')->take(null)->get();
        $softWareAqs = Item::where('type', 'aq')->where('kind', 1)->orderBy('created_at', 'DESC')->take(null)->get();
        return view('site.serviceAq', [
            'hardWareAqs' => $hardWareAqs,
            'softWareAqs' => $softWareAqs,
        ]);
        return view('site.serviceSupport');
    }

    public function getHome()
    {
        return redirect()->guest('admin');
    }
}